﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using JobbJakt;

namespace JobbJaktWeb
{
    public partial class CV : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["Authorization"] == null)
                {
                    Response.Redirect("Login.aspx");
                }

                if (Session["Authorization"].ToString() != "HeadHunter")
                {
                    Response.Redirect("Home.aspx");
                }
            }
        }

        protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string selectedItem = ListBox1.SelectedItem.Value;

            if (selectedItem != null)
            {

                List<Applications> app = Applications.GetApplicationsToList();

                var application = app.Find(a => a.AdvertisementID.ToString() == ListBox1.SelectedItem.Value);
                var users = Users.PrintUser(application.UserName);

                TextBoxFirstname.Text = users.FirstName;
                TextBoxLastName.Text = users.LastName;
                TextBoxAddress.Text = users.Address;
                TextBoxZipcode.Text = users.ZipCode;
                TextBoxCity.Text = users.City;
                TextBoxPhone.Text = users.Phone;
                TextBoxEmail.Text = users.Email;
                TextBoxInterest.Text = users.Interest;
                TextBoxAttributes.Text = users.Attributes;
            }
        }

        protected void TextBoxLastName_TextChanged(object sender, EventArgs e)
        {

        }
    }
}